//
//  SliderBtn.m
//  HotWord
//
//  Created by 贺 欢 on 13-3-17.
//
//

#import "SliderBtn.h"
#import "MessageManager.h"

@interface SliderBtn ()
@property (retain, nonatomic) IBOutlet UIImageView *messageMarkImageView;

@end

@implementation SliderBtn

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)dealloc
{
    [_messageMarkImageView release];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:NOTIFICATION_RECEIVE_MESSAGE object:nil];

    [super dealloc];
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    [self receiveMessageNotification];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveMessageNotification) name:NOTIFICATION_RECEIVE_MESSAGE object:nil];

}

- (void)receiveMessageNotification
{
    if ([MessageManager sharedManager].newMessageCount > 0)
    {
        _messageMarkImageView.hidden = NO;
    }
    else
    {
        _messageMarkImageView.hidden = YES;
    }
}



- (IBAction)tapOnSliderBtn:(id)sender
{
    [APP_DELEGATE showSliderView:!APP_DELEGATE.isSliderViewShowing];
}

@end
